################################################################################
##                                                                            ##
##   Software       :                                                         ##
##   Layer          : SRC                                                     ##
##   Package        :                                                         ##
##   Component      :                                                         ##
##                                                                            ##
##   File           : Makefile                                                ##
##   Author         : RSO ( Rafael Sotomayor Brûlé )                          ##
##   EMail          : rsotomayor@savtec.cl                                    ##
##   Type           : Make                                                    ##
##   Usage          : make -f Makefile                                        ##
##   Purpose        :                                                         ##
##                                                                            ##
##                                                                            ##
##   who when        what                                                     ##
##   ~~~ ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~##
##   RSO 09-10-2010  Creation                                                 ##
##                                                                            ##
################################################################################
# Modify to the path of your crosstools...
# CROSS_COMPILE = /home/user/crosstool/arm-unknown-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/arm-unknown-linux-gnu-

MYLIB_PATH=${HOME}/workspace/mylib/
MYHOME_PATH=${HOME}/workspace/migtk_base/

ifndef PLATFORM
  PLATFORM := $(shell uname -m)
endif

ifndef DIST
  DIST := $(shell lsb_release -i -s)
endif

ifeq ($(PLATFORM),TS4800-X)
CROSS_PATH=/usr/local/opt/ts/ts4800/
CROSS_COMPILE=${CROSS_PATH}/arm-2008q3/bin/arm-none-linux-gnueabi-g++
CROSS_INCLUDE=\
-I. \
-I${CROSS_PATH}/usr/include/ \
-I${MYLIB_PATH}/include \
-I${CROSS_PATH}/usr/include/libxml2/ \
-I${MYHOME_PATH}/src/util/ \
-I${CROSS_PATH}/usr/include/gtk-2.0 \
-I${CROSS_PATH}/usr/lib/gtk-2.0/include \
-I${CROSS_PATH}/usr/include/atk-1.0 \
-I${CROSS_PATH}/usr/include/cairo \
-I${CROSS_PATH}/usr/include/pango-1.0 \
-I${CROSS_PATH}/usr/include/gio-unix-2.0/ \
-I${CROSS_PATH}/usr/include/pixman-1 \
-I${CROSS_PATH}/usr/include/freetype2 \
-I${CROSS_PATH}/usr/include/libpng12 \
-I${CROSS_PATH}/usr/include/glib-2.0 \
-I${CROSS_PATH}/usr/lib/glib-2.0/include \
-I${CROSS_PATH}/usr/include/libglade-2.0 
CFLAGS=-D__TS4800__ -g -DS100_GTK -D"${DIST}"
CROSS_LIB=-L${MYLIB_PATH}/lib \
${CROSS_PATH}/lib/libc.so.6 \
${CROSS_PATH}/lib/libm.so.6 \
${CROSS_PATH}/lib/libpcre.so.3 \
${CROSS_PATH}/lib/libpng12.so.0 \
${CROSS_PATH}/lib/libpthread.so.0  \
${CROSS_PATH}/lib/libpthread.so.0 \
${CROSS_PATH}/lib/libselinux.so.1 \
${CROSS_PATH}/usr/lib/libatk-1.0.so \
${CROSS_PATH}/usr/lib/libcairo.so \
${CROSS_PATH}/usr/lib/libcom_err.so \
${CROSS_PATH}/usr/lib/libcrypto.so \
${CROSS_PATH}/usr/lib/libcurl.so \
${CROSS_PATH}/usr/lib/libexpat.so.1 \
${CROSS_PATH}/usr/lib/libfontconfig.so \
${CROSS_PATH}/usr/lib/libfreetype.so  \
${CROSS_PATH}/usr/lib/libfreetype.so \
${CROSS_PATH}/usr/lib/libgcrypt.so.11 \
${CROSS_PATH}/usr/lib/libgdk_pixbuf-2.0.so.0.2000.1 \
${CROSS_PATH}/usr/lib/libgdk-x11-2.0.so \
${CROSS_PATH}/usr/lib/libgio-2.0.so \
${CROSS_PATH}/usr/lib/libglade-2.0.so.0 \
${CROSS_PATH}/usr/lib/libglib-2.0.so \
${CROSS_PATH}/usr/lib/libgmodule-2.0.so.0 \
${CROSS_PATH}/usr/lib/libgnutls.so.26 \
${CROSS_PATH}/usr/lib/libgobject-2.0.so.0 \
${CROSS_PATH}/usr/lib/libgpg-error.so.0  \
${CROSS_PATH}/usr/lib/libgssapi_krb5.so.2 \
${CROSS_PATH}/usr/lib/libgthread-2.0.so.0 \
${CROSS_PATH}/usr/lib/libgtk-x11-2.0.so \
${CROSS_PATH}/usr/lib/libidn.so \
${CROSS_PATH}/usr/lib/libk5crypto.so \
${CROSS_PATH}/usr/lib/libkeyutils.so \
${CROSS_PATH}/usr/lib/libkrb5.so  \
${CROSS_PATH}/usr/lib/libkrb5support.so \
${CROSS_PATH}/usr/lib/libkrb5support.so.0 \
${CROSS_PATH}/usr/lib/liblber.so \
${CROSS_PATH}/usr/lib/libldap.so \
${CROSS_PATH}/usr/lib/libpango-1.0.so.0  \
${CROSS_PATH}/usr/lib/libpango-1.0.so.0 \
${CROSS_PATH}/usr/lib/libpangocairo-1.0.so.0 \
${CROSS_PATH}/usr/lib/libpangoft2-1.0.so.0 \
${CROSS_PATH}/usr/lib/libpixman-1.so.0 \
${CROSS_PATH}/usr/lib/libresolv.so \
${CROSS_PATH}/usr/lib/librt.so \
${CROSS_PATH}/usr/lib/libsasl2.so.2 \
${CROSS_PATH}/usr/lib/libsqlite3.so.0 \
${CROSS_PATH}/usr/lib/libssh2.so \
${CROSS_PATH}/usr/lib/libssl.so \
${CROSS_PATH}/usr/lib/libtasn1.so.3 \
${CROSS_PATH}/usr/lib/libX11.so.6 \
${CROSS_PATH}/usr/lib/libXau.so.6 \
${CROSS_PATH}/usr/lib/libxcb-render.so.0 \
${CROSS_PATH}/usr/lib/libxcb-render-util.so.0  \
${CROSS_PATH}/usr/lib/libxcb.so.1  \
${CROSS_PATH}/usr/lib/libxcb.so.1 \
${CROSS_PATH}/usr/lib/libXcomposite.so \
${CROSS_PATH}/usr/lib/libXcursor.so.1 \
${CROSS_PATH}/usr/lib/libXdamage.so \
${CROSS_PATH}/usr/lib/libXdmcp.so.6  \
${CROSS_PATH}/usr/lib/libXdmcp.so.6 \
${CROSS_PATH}/usr/lib/libXext.so.6 \
${CROSS_PATH}/usr/lib/libXfixes.so.3 \
${CROSS_PATH}/usr/lib/libXinerama.so.1 \
${CROSS_PATH}/usr/lib/libXi.so.6 \
${CROSS_PATH}/usr/lib/libxml2.so \
${CROSS_PATH}/usr/lib/libXrandr.so.2 \
${CROSS_PATH}/usr/lib/libXrender.so.1 \
${CROSS_PATH}/usr/lib/libz.so \
${CROSS_PATH}/usr/lib/libz.so.1 \
-lmylibarm4800
TARGET=migtk_base
else
CROSS_INCLUDE=-I. -I${MYLIB_PATH}/include  -I${MYHOME_PATH}/src/util/ 
CROSS_COMPILE=g++
CROSS_LIB=-L${MYLIB_PATH}/lib -lpthread -lmylib -lsqlite3 -lcurl -lcrypto  `pkg-config --libs gtk+-2.0 libglade-2.0`  -lX11
CFLAGS=`pkg-config --cflags gtk+-2.0 libglade-2.0` -D"${DIST}"
TARGET=migtk_base
endif

LIBS=${CROSS_LIB}
INCLUDE=${CROSS_INCLUDE}

OBJECTS=main.o myform.o formmain.o formconfig.o myconfig.o cconfig.o xsendkey.o myserver.o cglobal.o cdatabase.o cpost.o curlit.o myutil.o cxml.o myglobal.o

all:  ${OBJECTS}
	${CROSS_COMPILE} -o ${TARGET} ${OBJECTS} ${LIBS} 

main.o: main.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c main.cxx ${INCLUDE}

myform.o: myform.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c myform.cxx ${INCLUDE}

formmain.o: formmain.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c formmain.cxx ${INCLUDE}

formconfig.o: formconfig.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c formconfig.cxx ${INCLUDE}

xsendkey.o: xsendkey.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c xsendkey.cxx ${INCLUDE}
	
myserver.o: myserver.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c myserver.cxx ${INCLUDE}

myconfig.o: myconfig.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c myconfig.cxx ${INCLUDE}

myglobal.o: myglobal.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c myglobal.cxx ${INCLUDE}

cxml.o: ${MYHOME_PATH}/src/util/cxml.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c ${MYHOME_PATH}/src/util/cxml.cxx ${INCLUDE}

curlit.o: ${MYHOME_PATH}/src/util/curlit.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c ${MYHOME_PATH}/src/util/curlit.cxx ${INCLUDE}

cpost.o: ${MYHOME_PATH}/src/util/cpost.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c ${MYHOME_PATH}/src/util/cpost.cxx ${INCLUDE}

myutil.o: ${MYHOME_PATH}/src/util/myutil.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c ${MYHOME_PATH}/src/util/myutil.cxx ${INCLUDE}

cglobal.o: ${MYHOME_PATH}/src/util/cglobal.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c ${MYHOME_PATH}/src/util/cglobal.cxx ${INCLUDE}

cconfig.o: ${MYHOME_PATH}/src/util/cconfig.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c ${MYHOME_PATH}/src/util/cconfig.cxx ${INCLUDE}

cdatabase.o: ${MYHOME_PATH}/src/util/cdatabase.cxx
	${CROSS_COMPILE} ${CFLAGS} -Wall -c ${MYHOME_PATH}/src/util/cdatabase.cxx ${INCLUDE}


clean:
	rm -f *.o ${TARGET}

